package com.hmdp.askPack.controller;

import com.hmdp.dto.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/ask/session")
public class SessionController {
    @GetMapping("/getSession/{name}")
    public Result getCode(@PathVariable String name,  HttpSession session) {
        Object attribute = session.getAttribute(name);
        System.out.println("session id :" + session.getId());
        if (attribute  == null)
            return Result.fail("session中不存在属性" + name);
        return Result.ok(attribute .toString());
    }
}
